//
//  GuaziAppDelegate.h
//  Guazi
//
//  Created by koolearn on 11-4-17.
//  Copyright __MyCompanyName__ 2011. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "ImageStore.h"
#import "AccountViewController.h"
#import "User.h"
#import "PostViewController.h"
#import "WebViewController.h"
#import "FriendsViewController.h"
#import "SilenceFolloweeViewController.h"
#import "MyCardsViewController.h"


typedef enum {
    TAB_FRIENDS,
    TAB_REPLIES,
    TAB_MESSAGES,
    TAB_FAVORITES,
    TAB_SEARCH,
} TAB_ITEM;

typedef enum {
	GUAZI_TAB_FRIENDS,
	GUAZI_TAB_TWEETS,
	GUAZI_TAB_MESSAGES,
	GUAZI_TAB_SETTINGS
} TAB_PAGE;

NSInteger sortByScreenName( id a, id b, void *context );


@interface GuaziAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
    UIWindow *window;
    UITabBarController *tabBarController;
    int selectedTab;
	
	ImageStore* imageStore;
	User* user;
    BOOL isvalidateUser;
	
	PostViewController* postView;
	WebViewController* webView;
    
    //auto refresh
    NSTimeInterval                  autoRefreshInterval;
    NSTimer*                        autoRefreshTimer;
    NSDate*                         lastRefreshDate;
    
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@property (nonatomic, assign) int selectedTab;

@property (nonatomic, readonly) ImageStore* imageStore;
@property (nonatomic, retain) User* user;
@property (nonatomic, assign) BOOL isValidateUser;

@property (nonatomic, assign) PostViewController*   postView;


+ (void) showAlert:(NSString*)message;
+ (void) showAlert:(NSString*)title message:(NSString*)message;
+ (BOOL)isMyScreenName:(NSString*)screen_name;
+ (GuaziAppDelegate*) getAppDelegate;
+ (void)openAccountView:(UIViewController*)controller;
+ (void) openRegisterView:(UIViewController*)controller;

- (void) post: (id) sender;
- (void) postViewAnimationDidFinish:(BOOL)isDirectMessage;
- (void) postTweetDidSucceed:(NSDictionary*)dic;
- (void)tweetDidDelete:(TwitterClient*)client obj:(NSObject*)obj;
- (void)sendMessageDidSucceed:(NSDictionary*)dic;

- (void)openLinksViewController:(NSString*)text;
- (void)openWebView:(NSString*)url on:(UINavigationController*)nav;
- (void)openWebView:(NSString*)url;

- (void)toggleFavorite:(Status*)status;

- (UIViewController*) currentViewController;
- (UINavigationController*) currentNavigationController;
- (UIViewController*) currentTabRootViewController;
- (FriendsViewController*) friendsViewController;
- (MyCardsViewController*) myCardsViewController;
- (SilenceFolloweeViewController*) silenceViewController;

- (BOOL) isAccountRegistered;
- (BOOL) isAccountOpened;
- (void) switchUser:(User*)newUser;

//刷新操作
- (void) refreshFriendsTimeline;

@end
